<template>
  <div>
    <!-- <div class="bg_grey_all"></div> -->
    <van-row gutter="20" class="title_left">
      <van-col span="8" style="padding-top: 45px">
        <a @click="back" class="back_a" style="color: white; margin-left: 10px">
          返回
        </a>
      </van-col>
      <van-col
        span="8"
        style="text-align: center; color: white; padding-top: 45px"
        >{{ title }}</van-col
      >
      <van-col span="8"></van-col>
    </van-row>
    <van-row class="topMargin">
      <van-col span="24">
        <van-cell :title="subTitle" class="bg_grey" />
        <van-form>
          <van-field
            v-model="workFlow.approveMemo"
            autosize
            label="备注"
            type="textarea"
            maxlength="200"
            placeholder="请输入审批备注"
            show-word-limit
          />
          <van-field name="radio" label="单选框">
            <template #input>
              <van-radio-group v-model="isPass" direction="horizontal">
                <van-radio name="1">通过</van-radio>
                <van-radio name="2">不通过</van-radio>
              </van-radio-group>
            </template>
          </van-field>

          <div style="margin: 16px">
            <van-button block type="primary" @click="commit">提交</van-button>
          </div>
        </van-form>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import { Api } from "../../../api/api_config";
import { Toast } from 'vant'
import WorkFlow from "../../../model/workFlow";

export default {
  data() {
    return {
      title: "用车审批",
      subTitle: "填写用车审批信息",
      useRecord: {},

      currentUser: {},
      message: "",
      workFlow: {},
      url: "",
      method: "",
      isPass: "2",
      uploader: [],
      isCostDisabled: false,
    };
  },
  created() {
    this.initData();
  },
  mounted() {},
  methods: {
    initData() {
      this.$store.state.tab_show = false;
      this.useRecord = this.$store.state.useRecord;
      this.currentUser = this.$store.state.configuration.currentUser;
      this.workFlow = new WorkFlow();
      this.url =
        Api.useRecord.approve.url + "/" + this.useRecord.id + "/approve";
      this.method = Api.useRecord.approve.method;
    },
    back() {
      this.$router.push("/carUsage");
    },
    commit() {
      this.workFlow.isPass = this.isPass === "1" ? true : false;
      console.log(this.workFlow);
      let that = this;
      this.$axios({
        method: this.method,
        url: this.url,
        data: this.workFlow,
      })
        .then(function () {
          Toast.success("提交成功");
          that.$router.push("/approve");
        })
        .catch(function (e) {
          console.log(e);
        });
    },
  },
};
</script>

<style scoped>
</style>
